package sourceagile.server.gitFileRepository;

import java.io.File;

import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;

public class ConvertFileToJson {

	public static String FILE_PATH = "filePath";

	public static String FILE_NAME = "fileName";

	public static String DATE_MODIFIED = "dateModified";

	public static String FILE_AUTHOR = "fileAuthor";

	public static JSONObject convertFromGit(File file, String projectPath) {

		JSONObject entry = new JSONObject();

		try {

			entry.put(FILE_PATH,
					file.getPath().substring(projectPath.length() + 1));

			entry.put(FILE_NAME, file.getName());

			entry.put(DATE_MODIFIED, file.lastModified());

			// entry.put(FILE_AUTHOR, file.getAuthor());

		} catch (JSONException e) {

			e.printStackTrace();
		}

		return entry;
	}

}
